import Block from "../Game/Block";
import Board from "../Game/Board";
import Card from "../Game/Card";
import Grid from "../Game/Grid";
import { MainState } from "./GameEnum";
import { LevelData_1001 } from "./Level/LevelData_1001";
import { LevelData_1002 } from "./Level/LevelData_1002";
import { LevelData_1003 } from "./Level/LevelData_1003";
import { LevelData_1004 } from "./Level/LevelData_1004";
import { LevelData_1005 } from "./Level/LevelData_1005";
import { LevelData_1006 } from "./Level/LevelData_1006";
import { LevelData_1007 } from "./Level/LevelData_1007";
import { LevelData_1008 } from "./Level/LevelData_1008";
import { LevelData_1009 } from "./Level/LevelData_1009";
import { LevelData_1010 } from "./Level/LevelData_1010";
import { LevelData_1011 } from "./Level/LevelData_1011";
import { LevelData_1012 } from "./Level/LevelData_1012";
import { LevelData_Test } from "./Level/LevelData_Test";

//#region 常量
export const GameName = 'pypy';
export const GameVer = '1.0.0';

/** 游戏数据 */
export class GameData {
    static row: number = 4// 10; // 行数
    static row_game: number = GameData.row - 0; // 有效行数
    static col: number = 6// 20; // 列数

    // static size: number = 50; // 方块的尺寸

    static cell_width: number = 80;
    static cell_height: number = 80;
    static W: number = GameData.cell_width * GameData.col;
    static H: number = GameData.cell_height * GameData.row;

    static card_width: number = 80;
    static card_height: number = 80;

    public static MapData_CurrentLevel: any = [];
    // public static CurrentLevelDataList = [];
    /**关卡层数 */
    public static Leve_l_layer_count: number = 50;
    public static Leve_2_layer_count: number = 50;

    public static LayerList: cc.Node[] = null;
    public static Card_types: any = [];

    static 是否按住键盘下 = false;

    static 消除满足数量: number = 3// 4;
    static GameData: any;
    static Player1Data: any;
    static 获取消除满足数量(): number {
        return GameData.消除满足数量;
    }

    static gamePause = false;

    static 下落是否暂停 = false;

    static isFirstEnterMainScene = true;

    static isTouch = false;

    static currentBlock: Block = null;
    static currentSelectGrid: Grid = null;

    static arrGrids: any[][] = [];
    static arrBlocks: any[] = [];

    static arrCards: Card[] = [];
    static arrCardGroups: any[] = [];
    static arrBoard: Board[] = [];

    // static CardList: Card[] = [];

    static CurrentLevel = 0;
    static CurrentLevelData;

    static 装填list = [];
    static 撤凳子list = [];

    /** StartPos */
    static StartPos: cc.Vec2;
    /** CurrentPos */
    static CurrentPos: cc.Vec2;
    /** IsMouseDown  */
    static IsMouseDown: boolean = false;
    /** 是否可以操作 */
    static IsCanOperate: boolean = true;

    static 本回合是否完成消除 = false;

    static gameState;
    static mainState = MainState.空闲;
    static currentBlockGroupCreateIndex: number = 0;
    static currentLevelData_d = [];

    static TetrisData = [
        { tetris_id: 0, count: 1, name: "1格方块" },
        { tetris_id: 1, count: 2, name: "2格长条" },
        { tetris_id: 2, count: 3, name: "3格长条" },
        { tetris_id: 3, count: 3, name: "3格L" },
        { tetris_id: 4, count: 4, name: "4格长条" },
        { tetris_id: 5, count: 4, name: "4格方块" },
        { tetris_id: 6, count: 4, name: "4格L" },
        { tetris_id: 7, count: 4, name: "4格Z" },
        { tetris_id: 8, count: 4, name: "4格T" },

    ]

    static InitData() {
        GameData.arrGrids = [];
        GameData.arrBlocks = [];

        GameData.arrCardGroups = [];

        GameData.IsCanOperate = true;

        GameData.gamePause = false;
    }

    public static Get_CurrentLevel() {
        return GameData.CurrentLevel;
    }

    public static Get_LevelData(): any {
        let levelData = Levels[GameData.Get_CurrentLevel()];
        // console.log("Get_LevelData", levelData);

        return levelData;
    }

    public static Get_LevelData_up() {
        let levelData = GameData.Get_LevelData();
        let levelData_u = levelData.u
        // console.log("Get_LevelData_up", levelData_u);
        return levelData_u;
    }

    public static Get_LevelData_middle() {
        let levelData = GameData.Get_LevelData();
        return levelData.m;
    }

    public static Get_LevelData_down() {
        // let levelData = GameData.Get_LevelData();
        // return levelData.d;
        return GameData.currentLevelData_d;
    }

    static ClearData() {
        GameData.arrGrids = [];
        GameData.arrBlocks = [];

        // GameData.arrCardGroups = [];
        // GameData.IsCanOperate = true;
    }
}

export const Levels =
    [
        LevelData_Test,

        LevelData_1001,
        LevelData_1002,
        LevelData_1003,
        LevelData_1004,
        LevelData_1005,
        LevelData_1006,
        LevelData_1007,
        LevelData_1008,
        LevelData_1009,
        LevelData_1010,
        LevelData_1011,
        LevelData_1012,
    ]

// export const MapData_Layer =
// {

// }

/** 调试 */
window["GameData"] = GameData;